package com.freeter.modules.controller;


import com.freeter.modules.gjs.entity.User;
import com.freeter.modules.gjs.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
@RequestMapping("/users-mgmt")
public class UserController {
    @Autowired
    private UserService userService;

    // 用户管理页面
    @GetMapping("")
    public String usersMgmtPage() {
        return "users-mgmt";
    }

    // 获取用户列表
    @GetMapping("/list")
    public List<User> listUsers(HttpSession session) {
        return userService.listUsers(session);
    }

    // 修改密码
    @PostMapping("/change-password")
    public ResponseEntity<?> changePassword(@RequestBody Object req, HttpSession session) {
        return userService.changePassword(req, session);
    }
}